home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / felix / source / libinit.c < prev    next >
C/C++ Source or Header  |  1999-01-25  |  4KB  |  131 lines

  1. //*************************************************************************//
  2. // Filename:    LibInit.c
  3. // Autor:       Christian Taulien of Strange Intelligence
  4. // Purpose:     Library initializers and functions to be called by StartUp.c
  5. // Creation:    18. März 1998
  6. //*************************************************************************//
  7.  
  8. #include <exec/types.h>
  9. #include <exec/memory.h>
  10. #include <exec/libraries.h>
  11. #include <exec/execbase.h>
  12. #include <exec/resident.h>
  13. #include <exec/initializers.h>
  14.  
  15. #include <pragma/exec_lib.h>
  16.  
  17. #include <clib/gadtools_protos.h>
  18.  
  19. #include "global.h"
  20. #include "FelixBase.h"
  21.  
  22. ULONG SAVEDS L_OpenLibs(void);
  23. void  SAVEDS L_CloseLibs(void);
  24.  
  25. extern struct FelixBase *FelixBase;
  26.  
  27. struct ExecBase      *SysBase       = NULL;
  28. struct IntuitionBase *IntuitionBase = NULL;
  29. struct GfxBase       *GfxBase       = NULL;
  30. struct Library       *DOSBase       = NULL;
  31. struct Library       *RexxSysBase   = NULL;
  32. struct Library       *GadToolsBase  = NULL;
  33. struct Library       *UtilityBase   = NULL;
  34. struct Library       *DiskFontBase  = NULL;
  35. struct Library       *LocaleBase    = NULL;
  36.  
  37. char ExLibName [] = "Felix.api";
  38. char ExLibID   [] = "Felix " VERSION_S " (" __DATE2__ ")\r\n";
  39. char Copyright [] = "Written by Christian <City> Taulien of Strange Intelligence.";
  40.  
  41. extern ULONG InitTab[];
  42. extern APTR EndResident; /* below */
  43.  
  44. struct Resident ROMTag =     /* do not change */
  45. {
  46.   RTC_MATCHWORD,
  47.   &ROMTag,
  48.   &EndResident,
  49.   RTF_AUTOINIT,
  50.   VERSION,
  51.   NT_LIBRARY,
  52.   0,
  53.   &ExLibName[0],
  54.   &ExLibID[0],
  55.   &InitTab[0]
  56. };
  57.  
  58. APTR EndResident;
  59.  
  60. struct MyDataInit                      /* do not change */
  61. {
  62.   UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  63.   UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  64.   UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  65.   UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  66.   UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  67.   UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  68.   ULONG ENDMARK;
  69. } DataTab =
  70. {
  71.   INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  72.   0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  73.   INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  74.   INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  75.   INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  76.   0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  77.   (ULONG) 0
  78. };
  79.  
  80. ULONG SAVEDS L_OpenLibs(void)
  81. /*S*/
  82. {
  83.   TRACE("Entry");
  84.   SysBase = (*((struct ExecBase **) 4));
  85.  
  86.   if (DOSBase = OpenLibrary("dos.library", 37))
  87.   {
  88.     if (IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37))
  89.     {
  90.       if (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37))
  91.       {
  92.         if (RexxSysBase = OpenLibrary("rexxsyslib.library", 36))
  93.         {
  94.           if (GadToolsBase = OpenLibrary("gadtools.library", 39))
  95.           {
  96.             if (UtilityBase = OpenLibrary("utility.library", 37))
  97.             {
  98.               if (DiskFontBase = OpenLibrary("diskfont.library", 37))
  99.               {
  100.                 if (LocaleBase = OpenLibrary("locale.library", 39))
  101.                 {
  102.                   return TRUE;
  103.                 } // if
  104.               } // if
  105.             } // if
  106.           } // if
  107.         } // if
  108.       } // if
  109.     } // if
  110.   } // if
  111.  
  112. return FALSE;
  113. }
  114. /*E*/
  115.  
  116. void SAVEDS L_CloseLibs(void)
  117. /*S*/
  118. {
  119.   TRACE("Entry");
  120.   if(GfxBase)       CloseLibrary((struct Library *) GfxBase);
  121.   if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
  122.   if(DOSBase)       CloseLibrary((struct Library *) DOSBase);
  123.   if(RexxSysBase)   CloseLibrary((struct Library *) RexxSysBase);
  124.   if(GadToolsBase)  CloseLibrary((struct Library *) GadToolsBase);
  125.   if(UtilityBase)   CloseLibrary((struct Library *) UtilityBase);
  126.   if(DiskFontBase)  CloseLibrary((struct Library *) DiskFontBase);
  127.   if(LocaleBase)    CloseLibrary((struct Library *) LocaleBase);
  128. }
  129. /*E*/
  130.  
  131.